<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //从小到大排序
      var a = [5, 4, 1, 2, 3];
      for (var i = 0; i <= a.length - 1; i++) {
        for (var b = 0; b <= a.length - i - 1; b++) {
          if (a[b] > a[b + 1]) {
            var c = a[b];
            a[b] = a[b + 1];
            a[b + 1] = c;
          }
        }
      }
      console.log(a);
    </script>
  </body>
</html>
